﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LookUserName.aspx.cs" Inherits="ZLDC.Estate.CM.LookUserName" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>人员列表</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../js/jquery/style/jquery.hiAlerts.css" rel="stylesheet" type="text/css" />

    <script src="../js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../js/LexunJS.js" type="text/javascript"></script>

    <script src="../js/jShowDiv.js" type="text/javascript"></script>

    <script src="../js/jquery/jquery.hiAlerts-min.js" type="text/javascript"></script>

    <link href="../js/jquery.autocomplete/jquery.autocomplete.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        var currentPage = 1; // 当前页
        var pageSize = 13; // 每页显示多少条
        var pageall = 0; // 总页数
        var total = 0; // 总记录数
        var user_name = "";
        $(function() {
           showList(currentPage);

        });

        function showList(currentPage) {

            userName = $("#txtUserName").val();
            
            
            $("#divList").html("<img src=\"../images/loading.gif\" />"); // 清空列表
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerCustomer.ashx',
                data: 'act=GetUserList&page=' + currentPage + '&pagesize=' + pageSize + '&userName=' + userName,
                timeout: '10000',
                error: function() {
                    alert("系统繁忙,请稍候后试！");
                }, success: function(json) {
                    listCallBack(json);
                }
            });

         }
        function Search() {
            var userName = $("#txtUserName").val();

            if (userName == "") {
                alert("请输入姓名！");
                return;
            }



            $("#divList").html("<img src=\"../images/loading.gif\" />"); // 清空列表
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerCustomer.ashx',
                data: 'act=GetUserList&page=' + currentPage + '&pagesize=' + pageSize + '&userName=' + userName,
                timeout: '10000',
                error: function() {
                    alert("系统繁忙,请稍候后试！");
                }, success: function(json) {
                    listCallBack(json);
                }
            });

        }
        function listCallBack(response) {
            var json = eval("(" + response + ")");

            var record = json.record;
            
         
            if (record == null || record.length == 0) {
                $("#divList").html("<font color='red'>&nbsp;系统内暂无您查询的信息!</font>");
                $("#divPage").html("");
                return;
            }

            var page = json.page;

            currentPage = page.currentpage;
            pageall = parseInt(page.pageall);
            total = page.total;


            var arr = [];
            arr.push("<table id='table1' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
            arr.push("<tr>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("序号");
            arr.push("</td>");

            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("楼盘系统ID");
            arr.push("</td>");
            
            
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("用户");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("部门");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("岗位名称");
            arr.push("</td>");

            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
            arr.push("类型");
            arr.push("</td>");


            arr.push("</tr>");

           
            var recordLength = record.length;
            for (var i = 0; i < recordLength; i++) {




                if (i % 2 == 0)
                    arr.push("<tr id='tr_" + record[i].user_id + "'  bgcolor='#FFFFFF' style='cursor: pointer;' onclick=\"selectedTr('" + record[i].user_id + "')\">");
                else
                    arr.push("<tr id='tr_" + record[i].user_id + "' bgcolor='#EEEDED' style='cursor: pointer;' onclick=\"selectedTr('" + record[i].user_id + "')\">");


                arr.push("<td height='20' class='STYLE6'>");
                if (record[i].id == "")
                    arr.push("");
                else
                    arr.push("<input type='checkbox' name='checkbox_" + record[i].user_id + "' id='" + record[i].user_id + "' onclick=\"cbSelect(this, '" + record[i].id + "','" + record[i].user_name + "')\"  />");
                    
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].user_id);
                arr.push("</td>");

                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].id);
                arr.push("</td>");
                
                
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].user_name);
                arr.push("</td>");


                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].deptname);
                arr.push("</td>");

                

                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].station);
                arr.push("</td>");

                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].status);
                arr.push("</td>");



                arr.push("</tr>");
            }
            arr.push("</table>");
            $("#divList").html(arr.join('')); // 显示列表
            $("#divPage").html(""); // 清空

            var pageHtml = LexunJS.showPage(currentPage, pageall, "showList"); // 分页
            $("#divPage").html(pageHtml);
        }

        // 全选
        function cbSelectAll() {
            document.getElementById("hID").value = "";

            var cbAll = document.getElementById("checkboxAll");
            var checkList = document.getElementsByTagName("input");

            if (cbAll.checked) {
                for (var i = 0; i < checkList.length; i++) {
                    if (checkList[i].type == "checkbox" && checkList[i].id > 0) {
                        checkList[i].checked = true;
                        if (parseInt(checkList[i].id) > 0) LexunJS.addOrCutData(1, "hID", checkList[i].id);
                    }
                }
            }
            else {
                for (var i = 0; i < checkList.length; i++) {
                    if (checkList[i].type == "checkbox" && checkList[i].id > 0) {
                        checkList[i].checked = false;
                        if (parseInt(checkList[i].id) > 0) LexunJS.addOrCutData(0, "hID", checkList[i].id);
                    }
                }
            }
        }

        // 单选
        function cbSelect(obj, objvalue,objvalue1) {
            if (obj.checked) {
                LexunJS.addOrCutData(1, "hID", objvalue);
                LexunJS.addOrCutData(1, "hUserName", objvalue1);
            }
            else {
                LexunJS.addOrCutData(0, "hID", objvalue);
                LexunJS.addOrCutData(0, "hUserName", objvalue1);
            }
        }

        // 选中某行
        function selectedTr(id) {
            $("tr").removeClass("selected");
            $("#tr_" + id).addClass("selected");
        }


        function ReturnValue1() {
            var IdList = document.getElementById("hID").value;
            var hUserNameList = document.getElementById("hUserName").value;

            ///把“|”替换为“，”
            while (IdList.indexOf("|") != -1) {

                IdList = IdList.replace("|", ",");
            }

            while (hUserNameList.indexOf("|") != -1) {

                hUserNameList = hUserNameList.replace("|", ",");
            }

            IdList = IdList.substr(0, IdList.length - 1);
            hUserNameList = hUserNameList.substr(0, hUserNameList.length - 1);

            window.returnValue = IdList + "|" + hUserNameList;

            window.close();
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">

    <script src="../js/jquery.autocomplete.js" type="text/javascript"></script>

    <table border="0" cellspacing="1" cellpadding="3" style="margin-top: 10px; width: 100%;
        text-align: center;" bgcolor="#a8c7ce">
        <tr>
            <td style="background-color: #FFFFFF; text-align: center;">
                姓名：<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
                &nbsp;<input id="btnSearch" type="button" class="button_bak" onclick="Search()" value=" 查 询 " />
                <input id="btnReturnValue"  type="button" class="button_bak" value="取回"  onclick="ReturnValue1()"/>
                <font color="red">* 楼盘系统ID为空，不能取回该用户的信息，请登录楼盘系统！</font>
            </td>
        </tr>
        <tr>
            <td style="background-color: #FFFFFF; vertical-align: top;">
                <div id="divList">
                </div>
                <div id="divPage">
                </div>
            </td>
        </tr>
    </table>

    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $("#txtUserName").autocomplete("../Ajax/GetUserAuto.aspx", { minChars: 2, extraParams: { uname: function() { return escape($('#txtUserName').val()); } }, scrollHeight: 350, width: 180, max: 100 });
        });

    </script>
     <input id="hID" name="hID" type="hidden" />
     <input id="hUserName" name="hUserName" type="hidden" />
    </form>
</body>
</html>
